import java.lang.reflect.Array;

// 泛型类
class Arrays <T extends Comparable<T>> {
    public T getMax(T[] array){
        T max = array[0];
        for (int i = 0; i < array.length; i++){
            if (max.compareTo(array[i]) < 0){
                max = array[i];
            }
        }
        return max;
    }
}

//泛型方法
class Arrays2{
    public static <T extends Comparable<T>> T getMax(T[] arrays){
        T max = arrays[0];
        for (int i = 0; i < arrays.length; i++) {
            if (max.compareTo(arrays[i]) < 0){
                max = arrays[i];
            }
        }
        return max;
    }

}
public class Test2 {
    public static void main(String[] args) {
//        Arrays2 arrays2 = new Arrays2();
//        Integer max = arrays2.getMax(new Integer[]{1,4,2,7,9,0});
//        System.out.println(max);
        Integer max = Arrays2.getMax(new Integer[]{1,4,2,7,9,0});
        System.out.println(max);
    }
    public static void main1(String[] args) {
        Arrays<Integer> arrays = new Arrays<>();
        Integer[] array = {1,4,2,5,3};
        System.out.println(arrays.getMax(array));
    }
}
